]> git.r.bdr.sh - rbdr/super-polarity/blobdiff - Super Polarity/Actors/Actor.cs
Removes spaces.
[rbdr/super-polarity] / Super Polarity / Actors / Actor.cs
diff --git a/Super Polarity/Actors/Actor.cs b/Super Polarity/Actors/Actor.cs
deleted file mode 100644 (file)
index 588ff14..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Content;
-using Microsoft.Xna.Framework.Graphics;
-
-namespace SuperPolarity
-{
-    class Actor
-    {
-        protected Game game;
-
-        public List<Actor> Children;
-
-        // Graphics / In-Game
-        protected Texture2D Texture;
-        protected Vector2 Origin;
-        public bool Active;
-
-        // Physical Properties
-        public Vector2 Position;
-        protected Vector2 Velocity;
-        protected Vector2 Acceleration;
-        public float Angle;
-
-        // Constraints / Behavior
-        protected float MaxVelocity;
-        protected float AccelerationRate;
-
-        public int Width
-        {
-            get { return Texture.Width; }
-        }
-
-        public int Height
-        {
-            get { return Texture.Height; }
-        }
-
-        public Actor(Game newGame)
-        {
-            game = newGame;
-        }
-
-        public virtual void Initialize(Texture2D texture, Vector2 position)
-        {
-            Texture = texture;
-            Position = position;
-            Active = true;
-
-            Children = new List<Actor>();
-
-            Origin = new Vector2(Texture.Width / 2, Texture.Height / 2);
-            Velocity = new Vector2(0, 0);
-            Acceleration = new Vector2(0, 0);
-
-            MaxVelocity = 5;
-            AccelerationRate = 10;
-        }
-
-        public void AutoDeccelerate(GameTime gameTime)
-        {
-            if (Acceleration.X == 0 && Velocity.X > 0)
-            {
-                if (AccelerationRate * gameTime.ElapsedGameTime.TotalSeconds > Velocity.X)
-                {
-                    Velocity.X = 0;
-                    Acceleration.X = 0;
-                }
-                else
-                {
-                    Acceleration.X = -AccelerationRate;
-                }
-            }
-
-            if (Acceleration.X == 0 && Velocity.X < 0)
-            {
-                if (-AccelerationRate * gameTime.ElapsedGameTime.TotalSeconds < Velocity.X)
-                {
-                    Velocity.X = 0;
-                    Acceleration.X = 0;
-                }
-                else
-                {
-                    Acceleration.X = AccelerationRate;
-                }
-            }
-
-            if (Acceleration.Y == 0 && Velocity.Y > 0)
-            {
-                if (AccelerationRate * gameTime.ElapsedGameTime.TotalSeconds > Velocity.Y)
-                {
-                    Velocity.Y = 0;
-                    Acceleration.Y = 0;
-                }
-                else
-                {
-                    Acceleration.Y = -AccelerationRate;
-                }
-            }
-
-            if (Acceleration.Y == 0 && Velocity.Y < 0)
-            {
-                if (-AccelerationRate * gameTime.ElapsedGameTime.TotalSeconds < Velocity.Y)
-                {
-                    Velocity.Y = 0;
-                    Acceleration.Y = 0;
-                }
-                else
-                {
-                    Acceleration.Y = AccelerationRate;
-                }
-            }
-        }
-
-        public virtual void Update(GameTime gameTime)
-        {
-            Move(gameTime);
-            ChangeAngle();
-            CheckOutliers();
-        }
-
-        public virtual void Move(GameTime gameTime)
-        {
-            AutoDeccelerate(gameTime);
-
-            var maxVelocity = MaxVelocity;
-
-            Velocity.X = Velocity.X + Acceleration.X * (float)gameTime.ElapsedGameTime.TotalSeconds;
-            Velocity.Y = Velocity.Y + Acceleration.Y * (float)gameTime.ElapsedGameTime.TotalSeconds;
-
-            if (Velocity.X > MaxVelocity)
-            {
-                Velocity.X = MaxVelocity;
-            }
-
-            if (Velocity.X < -MaxVelocity)
-            {
-                Velocity.X = -MaxVelocity;
-            }
-
-            if (Velocity.Y > MaxVelocity)
-            {
-                Velocity.Y = MaxVelocity;
-            }
-
-            if (Velocity.Y < -MaxVelocity)
-            {
-                Velocity.Y = -MaxVelocity;
-            }
-
-            Position.X = Position.X + Velocity.X;
-            Position.Y = Position.Y + Velocity.Y;
-        }
-
-        public void ChangeAngle()
-        {
-            Angle = (float)Math.Atan2(Velocity.Y, Velocity.X);
-        }
-
-        public virtual void Draw(SpriteBatch spriteBatch)
-        {
-            foreach (Actor child in Children)
-            {
-                child.Draw(spriteBatch);
-            }
-
-            spriteBatch.Draw(Texture, Position, null, Color.White, Angle, Origin, 1f, SpriteEffects.None, 0f);
-        }
-
-        void CheckOutliers()
-        {
-            for (var i = Children.Count; i > 0; i--)
-            {
-                var actor = Children[i - 1];
-                if (actor.Position.X < -SuperPolarity.OutlierBounds || actor.Position.Y < -SuperPolarity.OutlierBounds ||
-                    actor.Position.X > game.GraphicsDevice.Viewport.Width + SuperPolarity.OutlierBounds ||
-                    actor.Position.Y > game.GraphicsDevice.Viewport.Height + SuperPolarity.OutlierBounds)
-                {
-                    Children.Remove(actor);
-                }
-            }
-        }
-    }
-}